package com.tian.view.anim.view_group_child

import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import com.tian.view.BaseRecyclerAdapter
import com.tian.view.common.BaseListFragment
import com.tian.view.helper.FragmentHelper

/**
 * @author tiansongtao, Email:tiansongtao@up366.com
 * @date 2022/12/29 14:14
 */
class ViewGroupAnimListFragment: BaseListFragment() {
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        (requireActivity() as AppCompatActivity).supportActionBar?.title = "ViewGroup子控件操作动画"
    }

    override fun getRecyclerViewAdapter(): BaseRecyclerAdapter {
        val adapter = BaseRecyclerAdapter()
        adapter.itemClickListener = object : BaseRecyclerAdapter.OnItemClickListener {
            override fun onItemClick(dataHolder: BaseRecyclerAdapter.DataHolder, position: Int) {
                val fragment = dataHolder.o1 as Fragment
                FragmentHelper.showFragment(requireActivity(), android.R.id.content, fragment, true,
                        dataHolder.o as String)
            }
        }
        return adapter
    }

    override fun onHiddenChanged(hidden: Boolean) {
        super.onHiddenChanged(hidden)
        if (!hidden) {
            (requireActivity() as AppCompatActivity).supportActionBar?.title = "ViewGroup子控件操作动画"
        }
    }


    override fun getAdapterData(): MutableList<BaseRecyclerAdapter.DataHolder> {
        val datas = mutableListOf<BaseRecyclerAdapter.DataHolder>()
        datas.add(BaseRecyclerAdapter.DataHolder(BaseRecyclerAdapter.TYPE_COMMON_BUTTON, "animateLayoutChanges",
                AnimateLayoutChangesFragment()))
        datas.add(BaseRecyclerAdapter.DataHolder(BaseRecyclerAdapter.TYPE_COMMON_BUTTON, "自定义LayoutTransition",
                LayoutTransitionFragemnt()))
        return datas
    }
}